Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-34699][SQL] 'CREATE OR REPLACE TEMP VIEW USING' should uncache correctly #31825

Closed
wants to merge 3 commits into from

Conversation

imback82
Copy link
Contributor

What changes were proposed in this pull request?

This PR proposes:

  1. CREATE OR REPLACE TEMP VIEW USING should use TemporaryViewRelation to store temp views.
  2. By doing Removed reference to incubation in README.md. #1, it fixes the issue where the temp view being replaced is not uncached.

Why are the changes needed?

This is a part of an ongoing work to wrap all the temporary views with TemporaryViewRelation: SPARK-34698.

This also fixes a bug where the temp view being replaced is not uncached.

Does this PR introduce any user-facing change?

Yes, the temp view being replaced with CREATE OR REPLACE TEMP VIEW USING is correctly uncached if the temp view is cached.

How was this patch tested?

Added new tests.

@github-actions github-actions bot added the SQL label Mar 14, 2021
// Replacing with a different relation. The cache should be cleared.
sql(s"CREATE OR REPLACE $tempViewStr ${ident.table} USING parquet OPTIONS (path '$path2')")
assert(!spark.catalog.isCached(viewName))
assert(spark.sharedState.cacheManager.isEmpty)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing code fails here because the temp view is not uncached.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit fragile to test cacheManager as it's global.

Can we create a new temp view with path1 and check if it's cached?

@HyukjinKwon
Copy link
Member

cc @MaxGekk @sunchao @cloud-fan FYI

@SparkQA
Copy link

SparkQA commented Mar 14, 2021

Test build #136034 has finished for PR 31825 at commit ba22dd0.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@cloud-fan
Copy link
Contributor

shall also we clean up the code in CreateViewCommand?

@SparkQA
Copy link

SparkQA commented Mar 15, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/40645/

@SparkQA
Copy link

SparkQA commented Mar 15, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/40645/

@SparkQA
Copy link

SparkQA commented Mar 15, 2021

Test build #136062 has finished for PR 31825 at commit 6813754.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@sunchao
Copy link
Member

sunchao commented Mar 15, 2021

Good catch on the cache issue! Unrelated: do we have documentation for the CREATE OR REPLACE TEMP VIEW USING clause? can't find it in this page.

@imback82
Copy link
Contributor Author

shall also we clean up the code in CreateViewCommand?

Do you mean removing this condition?

If so, I am planning to address it with SPARK-34700, in which we can change the signature of getRawTempView: imback82@f1c86b8. I can still change it here in this PR, but SPARK-34700 will modify it a bit again. Please let me know which one you prefer. Thanks!

@SparkQA
Copy link

SparkQA commented Mar 15, 2021

Test build #136076 has started for PR 31825 at commit d476bce.

@cloud-fan
Copy link
Contributor

@imback82 let's leave it to your follow-up work.

@imback82
Copy link
Contributor Author

retest this please

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 387d866 Mar 17, 2021
cloud-fan pushed a commit that referenced this pull request Mar 22, 2021
…d take/return more concrete types

### What changes were proposed in this pull request?

Now that all the temporary views are wrapped with `TemporaryViewRelation`(#31273, #31652, and #31825), this PR proposes to update `SessionCatalog`'s APIs for temporary views to take or return more concrete types.

APIs that will take `TemporaryViewRelation` instead of `LogicalPlan`:
```
createTempView, createGlobalTempView, alterTempViewDefinition
```

APIs that will return `TemporaryViewRelation` instead of `LogicalPlan`:
```
getRawTempView, getRawGlobalTempView
```

APIs that will return `View` instead of `LogicalPlan`:
```
getTempView, getGlobalTempView, lookupTempView
```

### Why are the changes needed?

Internal refactoring to work with more concrete types.

### Does this PR introduce _any_ user-facing change?

No, this is internal refactoring.

### How was this patch tested?

Updated existing tests affected by the refactoring.

Closes #31906 from imback82/use_temporary_view_relation.

Authored-by: Terry Kim <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants